// const baseUrl='http://192.168.153.1:3000'

const baseUrl='http://localhost:3000';
const request = (url,method,data) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: baseUrl + url,
			data,
			method,
			header: {
				'content-type': 'application/json',
				'Authorization': uni.getStorageSync('token')||{}
			},
			success: (res) => {
				resolve(res.data)
			},
			fail: (err) => {
				console.log(err)
				// 页面中弹框显示失败
				uni.showToast({
					icon: "none",
					duration: 1500,
					title: '请求接口失败'
				})
				// 返回错误消息
				reject(err)
			},
			catch: (e) => {
				console.log(e);
			}
		})
	})
}
export default request